home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / vb / bitmap.exe / FOPEN.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1991-07-10  |  11.1 KB  |  200 lines

  1.     FOpenForm
  2.     File Open
  3. wwwwwwwwwp
  4. wwwwwwwwwp
  5. wwwwwwwwwp
  6. Form1*
  7. Text1
  8. FileName
  9. Command1
  10. &Open
  11. FNameLabel
  12. File &Name:
  13. Label4
  14. Directory:
  15. Label1
  16. Label1
  17. Command2
  18. &Cancel
  19. FilesLabel
  20. &Files:
  21. DirLabel
  22. &Directories:
  23. Command3
  24. Load &Null
  25. File1
  26. List1
  27. TheFocus
  28.     List1Flag@
  29.     Text1Flag
  30. TheDriveI
  31. LastChange
  32. @    Form_Load
  33.     FormTitle>
  34.     FOpenForm
  35. caption7
  36. ThePath
  37. File1
  38. ThePattern
  39. Pattern
  40. Text1b
  41. Textr
  42. Label1
  43. Form_GotFocus|
  44. List1 
  45. List1_GotFocus
  46. GetFocus
  47. SendMessageY
  48. LB_DIR
  49.     BuildSpec
  50. selstart
  51.     sellength
  52. visible
  53. List1_Dblclick
  54.     Listindex
  55. curnt
  56. OldPath
  57. ChangeDrive
  58. ErrState
  59. LB_RESETCONTENT
  60. List1_KeyPress}
  61. KeyAsciik
  62. File1_Click
  63. FileName
  64. File1_KeyPress
  65. File1_DblClick
  66. Command1_Click
  67. Text1_Keypress
  68. RemoveSpaces
  69.     Listcount<
  70. TheFileNameV
  71. Foundit
  72. true7
  73. false
  74. tempom
  75. ProcessEntry
  76. @    ChangeDir
  77.     TheStructv
  78. OfStruct
  79. OpenFile
  80. OF_EXIST
  81. lclose
  82. FullName
  83. Text1_Change[
  84. List1_Clicke
  85. TheText
  86. Command2_Click
  87. fpath
  88. Text1_GotFocus
  89.     TextLimit
  90. EM_LIMITTEXT
  91. CompleteName
  92. ErrCodeK
  93. DirLabel_Click
  94. Label4_Click
  95. Change
  96. empty
  97. Command4_Click
  98. Command3_Click
  99. You are welcome to use FOPEN in your programs free of charge."
  100. If you make any improvements send me a copy at CIS-MAL 73667,1755e
  101. Costas Kitsosn
  102.  Handle for Drive/Subdirectory ListBox
  103.  Flag for Drive/Subdirectory ListBox 0 or 1M
  104.  Flag for EM_LIMITTEXT
  105.  The selected driveE
  106.  Flag used when processing selectionsM
  107. Form_Load
  108.  Set the flags for List1 and Text1 e
  109.  Update Drive/Subdirectory listbox
  110.  Limit text length r
  111.  If the Parent didn't specify a FormTitle use the one that's built in.
  112. File Open"
  113.  otherwise honor the Parent's specifications
  114.  If there is a path specification use it, otherwise use the default.
  115.  If the Parent specified a new pattern then use it. 
  116.  Finish up loading the form.
  117. Form_GotFocus
  118.  Set the Focus on List1 to fill the ListBoxh
  119. List1_GotFocus
  120.  get the handle of the ListBox
  121.  fill it with the Drive/Subdirectory listing
  122.  update the flag so we don't go through this every timeo
  123.  highlight Text1
  124. List1_Dblclick
  125.  List1 holds both drives and subdirectoriess
  126. get the current selectione
  127. save the old path in case of error
  128.  if the user chose a drive parse it and change to it
  129.  if the user chose a subdirectory change to it
  130.  LB_RESETCONTENT clears the list fastn
  131.  LB_DIR specifies the type of listbox, &HC010 specifies drives and subdirectories only.l
  132.  if there was an error let the user know.C
  133. List1_KeyPress
  134.  if the user presses the Return key while on a valid entry, invoke a List1_DblClickn
  135. File1_Click
  136.  update the textbox and the lastchange flagn
  137. File1_KeyPress
  138.  if Return, select File1_DblClickh
  139. File1_DblClick
  140.  Good, we have a file, let's tell Command1
  141. Text1_Keypress
  142.  process whatever the user typed in Text11
  143.  get rid of the beep (Mark, thanks for the tip)t
  144.  remove any space characters.  Some users put a space after a period out of habit.
  145.  see if the file is in File1.List. If it is, we're done so let's tell Command1.i
  146.  if the file is not in File1.List let's see what the user is trying to do.
  147. drive?
  148. subdirectory? 
  149. wildcards?
  150. flag used by ChangeDrive
  151. if we found a drive change to it
  152.  If changing to the drive didn't cause any errors or if a drive wasn't specified
  153.  if a subdirectory was specified
  154.  newd$ holds everything to the left of the last backslash 
  155.  tempo$ hold the rest.  Now, process them.
  156.  did the user specify only a new pattern?.
  157.  highlight the text
  158. ChangeDrive
  159.  try to change to the new drivew
  160.  if an error occurred go back to the way things were
  161. change the flag so Text1 knows
  162. ChangeDir
  163.  change to the new directory and update List1g
  164.  you may add a MsgBox error message here if you think it's
  165.  necessary.y
  166. ProcessEntry
  167.  we'll use this if/when we have to use OpenFile
  168.  if a$(newd$) isn't empty change to it.O
  169. if b$(tempo$) isn't empty let's see what it could be.
  170. if it's a new pattern then let File1.List know
  171. otherwise could it be a file?
  172. use OpenFile to see if it exists.  If so x% will return a file handle.
  173. This is a very useful API function.I
  174. close the file
  175. if we have a file handle, we're done let's tell Command1
  176. no handle? The user probably specified a subdirectory.
  177. Text1_Change
  178. needed by Command1
  179. Command1_Click
  180. process Text1 entryT
  181. we have a file, put together the FullNamei
  182. let List1 know
  183. we have a file and a FullName
  184. we have a file, put together the FullName
  185. List1_Click
  186.  let Command1 know
  187. RemoveSpaces
  188.  squeezes out spaces
  189. Command2_Click
  190.  did the user press cancel?p
  191.  Change FullName to "CANCEL" so the Parent knows.s
  192. CANCEL
  193. BuildSpec
  194.  builds the spec for SendMessage
  195. Text1_GotFocus
  196.  Do this only once
  197.  send the message to limit the text entry to not more than 127 characterse
  198. Command3_Click
  199.  The user pressed Load Null, so set FullName to ""
  200.